/*
* Copyright (c) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Camerality OpenGL Renderer for a window.
*
*/

#ifndef CAMERALITYGLRENDERER_H_
#define CAMERALITYGLRENDERER_H_

// INCLUDES
#include <EGL/egl.h>
#include <GLES/gl.h>

// FORWARD DECLARATIONS
class CPeriodic;
class CAlfCompositionSource;

// CLASS DECLARATION
class CCameralityGLRenderer : public CBase
    {
public:
    static CCameralityGLRenderer* NewL();
    virtual ~CCameralityGLRenderer();

public: // New methods
    void Start(RWindow& aWindow);
    void Resize(const TSize& aSize);
    void Stop();
    EGLDisplay Display() const;

private: // Private methods
    static TInt RenderCallback(TAny* aInstance);
    void SetupScene();
    TInt RenderScene();
    void DrawBox(GLfixed aSizeX, GLfixed  aSizeY, GLfixed aSizeZ);

private: // Private constructors
    CCameralityGLRenderer();
    void ConstructL();

private: // Data
    enum TState {
        EIdle,
        ERendering
    };

    /** State of the renderer. */
    TState iState;

    /** Display where the OpenGL ES window surface resides. */
    EGLDisplay  iEglDisplay;

    /** Window surface where the OpenGL ES rendering is blitted to. */
    EGLSurface  iEglSurface;

    /** OpenGL ES rendering context. */
    EGLContext  iEglContext;
    EGLConfig   iConfig;

    /** Active object that is the timing source for the animation. */
    CPeriodic*  iPeriodic;

    CAlfCompositionSource* iCompSource;

    RWindow* iWindow;
    TUint iScreenWidth;
    TUint iScreenHeight;

    TInt iFrame;
    };

#endif /* CAMERALITYGLRENDERER_H_ */
